package design_pattern.decorator.demo01;

/**
 * @version 1.0.0
 * Created by cyd on 2022-06-06 11:35:36
 * @ClassName : design_pattern.decorator.demo01.Client
 * @Description : 客户端使用装饰器的演示
 */
public class Client {
    public static void main(String[] args) {
        ConcreteComponent concreteComponent = new ConcreteComponent();

        // 不同的装饰器
        ConcreteDecoratorA decoratorA = new ConcreteDecoratorA();
        ConcreteDecoratorB decoratorB = new ConcreteDecoratorB();

        // 装饰器要设置装饰对象
        decoratorA.setComponent(concreteComponent);
        decoratorB.setComponent(concreteComponent);

        // 装饰器调用operation方法，实际上是先调用未经过装饰的方法，再调用自己的独有的装饰方法
        decoratorA.operation();
        decoratorB.operation();
    }
}
